package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.saas.domain.dao.ClueConvertRuleDao;
import com.xbongbong.saas.domain.entity.ClueConvertRuleEntity;
import com.xbongbong.saas.model.ClueConvertRuleModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * @author long
 * @version v1.0
 * @date 2020/11/26 13:58
 * @since v1.0
 */
@Service("clueConvertRuleModel")
public class ClueConvertRuleModelImpl implements ClueConvertRuleModel {

    @Resource
    private ClueConvertRuleDao clueConvertRuleDao;

    @Override
    public List<ClueConvertRuleEntity> getByCorpidAndFormId(String corpid, Long formId) {
        return clueConvertRuleDao.getByCorpidAndFormId(corpid, formId);
    }
    @Override
    public ClueConvertRuleEntity getByCustomerFormId(String corpid, Long formId,Long customerFormId) {
        return clueConvertRuleDao.getByCustomerFormId(corpid, formId,customerFormId);
    }

    @Override
    public Integer insert(ClueConvertRuleEntity entity) throws XbbException {
        return clueConvertRuleDao.insert(entity);
    }

    @Override
    public Integer update(ClueConvertRuleEntity entity) throws XbbException {
        return clueConvertRuleDao.update(entity);
    }

    @Override
    public void save(ClueConvertRuleEntity entity) throws XbbException {
        if (Objects.isNull(entity.getId())) {
            clueConvertRuleDao.insert(entity);
        } else {
            clueConvertRuleDao.update(entity);
        }
    }

    @Override
    public List findEntitys(Map<String, Object> param) {
        return clueConvertRuleDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return clueConvertRuleDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }


}
